package com.crl.rcdp.monitor.service;

import com.cars.util.http.HttpUtil;
import com.crl.rcdp.monitor.vo.MonitorEurekaVO;
import org.springframework.stereotype.Service;

/**
 * @description:
 * @author: 孔垂云
 * @version: 1.0
 * @date: 2020/8/9 0:28
 */
@Service
public class MonitorEurekaService {
    /**
     * 上线
     *
     * @return
     */
    public int up(MonitorEurekaVO monitorEurekaVO) {
        int flag = 0;
        String url = monitorEurekaVO.getUri() + "/actuator/service-registry";
        String param = "{\"status\":\"UP\"}";
        String str = HttpUtil.postJson(url, param);
        System.out.println(str);
        flag = 1;
        return flag;
    }

    /**
     * 下线
     *
     * @return
     */
    public int down(MonitorEurekaVO monitorEurekaVO) {
        int flag = 0;
        String url = monitorEurekaVO.getUri() + "/monitor/shutdown";
        String param = "{\"status\":\"DOWN\"}";
        String str = HttpUtil.postJson(url, param);
        System.out.println(str);
        flag = 1;
        return flag;
    }

}
